export type Role = "Administrator" | "Operator";

export type User = {
  // role: Role;
  nickName: string;
};

export type IRequestListParams<T = object> = {
  pageNum?: number;
  pageSize?: number;
} & T;

export type IResponse<T = object> = {
  code: number;
  msg: string;
} & T;

export type IResponseList<T = object> = IResponse<T> & { total: number };

export type IDevice = {
  deviceId: number;
  deviceName: string;
  humidityHigh: number;
  humidityLow: number;
  imagePath: string;
  ip: string;
  protocol: string;
  isAutoReconnect: number;
  isHumidity: number;
  isPressure: number;
  isTemperature: number;
  makerId: number;
  number: string;
  port: string;
  pressureHigh: number;
  pressureLow: number;
  regionId: number;
  status: string;
  store: string;
  storeIntervalTime: number;
  temperatureHigh: number;
  temperatureLow: number;
  type: string;
  alarms: {
    id: string;
    name: string;
    sign: string;
  }[];
  monitors: {
    address: string;
    enabled: "0" | "1";
    id: number;
    ip: string;
    name: string;
    port: string;
    protocol: string;
    serialPort: string;
    baudRate?: number;
    rsMode?: string;
    pointType: string;
    multiple: string;
    unitName: string;
    lowerLimit?: number;
    upperLimit?: number;
    dataBits?: string;
    parity?: string;
    stopBits?: string;
    dataType?: string;
  }[];
};

export type IMaker = {
  makerId: number;
  makerName: string;
};

export type IRegion = {
  regionId: number;
  regionName: string;
};

export type ILimitWarning = {
  hWarningLimitLower: number;
  hWarningLimitUpper: number;
  pWarningLimitLower: number;
  pWarningLimitUpper: number;
  tWarningLimitLower: number;
  tWarningLimitUpper: number;
  createBy: string;
  createTime: string;
  params: object;
  remark: string;
  updateBy: string;
  updateTime: string;
};

export type IProgram = {
  createBy: string;
  createTime: string;
  linkProgramId: string;
  loop: number;
  programId: number;
  programName: string;
  remark: string;
  updateBy: string;
  updateTime: string;
};

export type IProgramStatus = {
  createBy: string;
  createTime: string;
  id: number;
  programId: number;
  remark: string;
  segmentLoop: number;
  segmentNo: number;
  stepHIsRate: string;
  stepHIsWait: string;
  stepHRateValue: number;
  stepHSv: number;
  stepHour: number;
  stepIsH: string;
  stepIsP: string;
  stepIsT: string;
  stepMinute: number;
  stepNo: number;
  stepPIsRate: string;
  stepPIsWait: string;
  stepPRateValue: number;
  stepPSv: number;
  stepPUnit: number;
  stepSecond: number;
  stepSv1: number;
  stepSv2: number;
  stepSv3: number;
  stepSv4: number;
  stepTIsRate: string;
  stepTIsWait: string;
  stepTRateValue: number;
  stepTSv: number;
  stepTime: number;
  stepTs: string;
  updateBy: string;
  updateTime: string;
};

export type IDeviceConstant = {
  createBy: string;
  createTime: string;
  updateBy: string;
  updateTime: string;
  remark: string;
  deviceId: number;
  isT: string;
  tSv: number;
  tRateValue: number;
  tIsRate: string;
  isH: string;
  hSv: number;
  hRateValue: number;
  hIsRate: string;
  isP: string;
  pSv: number;
  pRateValue: number;
  pIsRate: string;
  pUnit: number;
  isTime: string;
  limitTimeHour: number;
  limitTimeMinute: number;
  limitTimeSecond: number;
  limitTime: number;
  isSv1: string;
  sv1: number;
  isSv2: string;
  sv2: number;
  isSv3: string;
  sv3: number;
  isSv4: string;
  sv4: number;
  isLimitWarning: string;
  tWarningLimitUpper: number;
  tWarningLimitLower: number;
  hWarningLimitUpper: number;
  hWarningLimitLower: number;
  pWarningLimitUpper: number;
  pWarningLimitLower: number;
  isMeasureWarning: string;
};

export type IDeviceProgram = {
  createBy: string;
  createTime: string;
  updateBy: string;
  updateTime: string;
  remark: string;
  deviceId: number;
  programId: number;
  currentLoop: number;
  currentSegmentNo: number;
  currentSegmentLoop: number;
  currentStepNo: number;
  runningTime: number;
  stepRunningTime: number;
  programData: IProgramStatus[];
  isLimitWarning: "0" | "1";
  tWarningLimitUpper: number;
  tWarningLimitLower: number;
  hWarningLimitUpper: number;
  hWarningLimitLower: number;
  pWarningLimitUpper: number;
  pWarningLimitLower: number;
  isMeasureWarning: "0" | "1";
  startTime: string;
  programName: string;
  loop: number;
};

export type IDeviceStatus = {
  deviceId: number;
  deviceName: string;
  regionId: number;
  /** 0停用 1启用 */
  status: "0" | "1";
  /** 1 停机，2 运行，3 保持 */
  deviceStatus: "1" | "2" | "3";
  deviceControl: boolean;
  confirmTakeControl: boolean;
  readError: boolean;
  warnings: { warningName: string }[];
  alarms: { alarmName: string }[];
  conn: boolean;
  h: boolean;
  hPv: number;
  tPv: number;
  tSv: number;
  tAv: number;
  hSv: number;
  hAv: number;
  t: boolean;
  p: boolean;
  punit: number;
  tStatus: -1 | 0 | 1;
  hStatus: -1 | 0 | 1;
  pStatus: -1 | 0 | 1;
  hLeftTime: number;
  pPv: number;
  pSv: number;
  pAv: number;
  pLeftTime: number;
  tLeftTime: number;
  isTemperature: 0 | 1;
  isHumidity: 0 | 1;
  isPressure: 0 | 1;
  isTime: 0 | 1;
  mode: "program" | "fix";
};

export type IDeviceProgramModeRunningStatus = {
  mode: "program";
  modelName: string;
  modelNo: string;
  orderNo: string;
  exerimentItem: string;
  deviceId: number;
  runTime: number;
  stepRunTime: number;
  leftTime: number;
  stepLeftTime: number;
  leftPer: number;
  stepLeftPer: string;
  setTime: string;
  programName: string;
  stepNo: string;
  segmentNo: string;
  loop: string;
  startTime: string;
  predictEndTime: string;
  loopTimes: {
    loop: number;
    startTime: string;
    endTime: string;
  }[];
};

export type IDeviceFixModeRunningStatus = {
  mode: "fix";
  modelName: string;
  modelNo: string;
  orderNo: string;
  exerimentItem: string;
  deviceId: number;
  runTime: number;
  stepRunTime: string;
  leftTime: number;
  stepLeftTime: string;
  leftPer: number;
  stepLeftPer: string;
  setTime: number;
  programName: string;
  stepNo: string;
  segmentNo: string;
  loop: string;
  startTime: string;
  predictEndTime: string;
  loopTimes: string;
};

export type IDeviceOperationLog = {
  createBy: string;
  createTime: string;
  updateBy: string;
  updateTime: string;
  remark: string;
  operId: number;
  title: string;
  businessType: number;
  businessTypes: string;
  method: string;
  requestMethod: string;
  operatorType: number;
  operName: string;
  deptName: string;
  operUrl: string;
  operIp: string;
  operLocation: string;
  operParam: string;
  jsonResult: string;
  status: number;
  errorMsg: string;
  operTime: string;
  costTime: number;
  businessSearch: string;
};

export type IDeviceAlarmLog = {
  deviceId: number;
  deviceName: string;
  alarmName: string;
  alarmTime: string;
  alarmType: "device" | "running";
};

export type IOrder = {
  createBy: string;
  createTime: string;
  deviceId: number;
  deviceName: string;
  experimentItem: string;
  modelName: string;
  modelNo: string;
  orderId: number;
  orderNo: string;
  orderStatus: string;
  programId: number;
  programName: string;
  remark: string;
  startTime: string;
  endTime: string;
  updateBy: string;
  updateTime: string;
};
